package com.aiatomic.couting.account;

import java.util.ArrayList;
import java.util.List;

import com.aiatomic.couting.models.TemplateEntity;

public class CurrencyChangeEventDispatcher {
	public static final int EVENT_CODE_DAYS = 0;
	private static CurrencyChangeEventDispatcher _instance;
	private List<CurrencyChangeEventListener> listenters;

	private CurrencyChangeEventDispatcher() {
		listenters = new ArrayList<CurrencyChangeEventListener>();
	}

	public static CurrencyChangeEventDispatcher getInstance() {
		if (_instance == null) {
			_instance = new CurrencyChangeEventDispatcher();
		}
		return _instance;
	}

	public void dispatchEvent(int eventCode) {
		for (CurrencyChangeEventListener listen : listenters) {
			listen.onCurrencyChangeEvent(eventCode);
		}
	}

	public void registListener(CurrencyChangeEventListener listener) {
		listenters.add(listener);
	}

	public void removeListener(CurrencyChangeEventListener listener) {
		if (listenters.contains(listener))
			listenters.remove(listener);
	}

	public void clean() {
		listenters.clear();
	}
}
